<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>09-vuex加减的例子-getter 版本</title>
</head>
<body>
    <div id="app">
        <button>显示仓库的内容</button>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vuex/dist/vuex.js"></script>
    <script src="./node_modules/axios/dist/axios.js"></script>
    <script>
        //2.创建vux数据仓库
        let store = new Vuex.Store({
            getters:{
              totalPrice:(state)=>{
                  console.log(this);
                  return state.counter * 10;
                  
              }
            },
            //仓库数据
          state:{
              counter:888
          },
          //改变值的操作
          mutations:{
              inscrement:function(state,count){
                state.counter+=count;
              }
          },
          //提交异步的操作
          actions:{
              asyncIncrement:function(store){
                //执行异步的操作
                axios.get("http://linweiqin.cn:8001/statis/admin/2020-10-17/count").then(res=>{
                    console.log(res.data.count);
                    store.commit("increment",res.data.count);
                    
                }).catch(err=>console.log(err))
              }
          }
        })
        let vm = new Vue({
            el:"#app",

        })
    </script>
</body>
</html>